#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    int repeat;
    cin>>repeat;
    char inputStr[128];
    //用一个指针数组，通过初试化完成
    const char * pStrArray[7] = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"};
    
    const char * p = "Sunday";
    
    
    for(int i = 0; i<repeat; i++)
    {
        cin >> inputStr;
        bool bIfFind = false;
        for(int j = 0; j<7; j++)
        {
            if(strcmp(pStrArray[j],inputStr) == 0)
            {
                cout<<j+1<<endl;
                bIfFind = true;
                break;
            }
        }
        if(!bIfFind)
            cout<<-1<<endl;
        
    }
}